package A2014;

public class _6_六角填数 {

	static int[] arr = { 2, 4, 5, 6, 7, 9, 10, 11, 12 };
	static int[] sum = { 0, 0, 0, 0, 0, 0 };

	public static void main(String[] args) {
		f(0);
	}

	private static void f(int i) {
		if (i >= 9) {
			sum[0] = 1 + arr[0] + arr[1] + arr[2];
			sum[1] = arr[2] + arr[3] + arr[4] + arr[5];
			sum[2] = 1 + arr[5] + arr[6] + arr[7];
			sum[3] = 8 + 3 + arr[5] + arr[7];
			sum[4] = 3 + arr[3] + arr[1] + arr[8];
			sum[5] = 8 + arr[7] + arr[0] + arr[8];
			if (sum[0] == sum[1] && sum[1] == sum[2] && sum[2] == sum[3] && sum[3] == sum[4] && sum[4] == sum[5]) {
				for(int b=0;b<arr.length;b++) {
					System.out.print(arr[b]+" ");
				}
			}
				return;
		}
		for (int j = i; j < 9; j++) {
			int t = arr[i];
			arr[i] = arr[j];
			arr[j] = t;
			f(i + 1);
			t = arr[i];
			arr[i] = arr[j];
			arr[j] = t;
		}
	}

}
